import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';

export const columns: BasicColumn[] = [
  {
    title: '提交(购买)日期',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '延误险编号',
    dataIndex: 'delayriskNo',
    width: 100,
  },
  {
    title: '预约来源',
    dataIndex: 'sourceType',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const sourceTypeArray = [
        { label: '公众号购买', value: 1 },
        { label: '会员卡权益使用', value: 2 },
      ];
      const sourceType: any = sourceTypeArray.find(item => item.value == record.soureType);
      if (sourceType) {
        return sourceType.label;
      }
      return '';
    },
  },
  {
    title: '被保险人数量',
    dataIndex: 'insurantNumber',
    width: 100,
  },
  {
    title: '未成年人数量',
    dataIndex: 'minorNumber',
    width: 100,
  },
  {
    title: '支付状态',
    dataIndex: 'orderStatus',
    width: 100,
    customRender: ({ record }: Recordable) => {
      const orderStatusArray = [
        { label: '无需支付', value: '' },
        { label: '待付款', value: 1 },
        { label: '已付款', value: 2 },
        { label: '已退款', value: 3 },
      ];
      const orderStatus: any = orderStatusArray.find(item => item.value == record.orderStatus);
      if (orderStatus) {
        return orderStatus.label;
      }
      return '';
    },
  },
  {
    title: '预约状态',
    dataIndex: 'appointmentState',
    width: 100,
    customRender: ({ record }: Recordable) => {
      const appointmentStates = [
        { label: '待购买', value: 0 },
        { label: '购买成功', value: 1 },
        { label: '购买失败', value: 2 },
      ];
      const appointmentState: any = appointmentStates.find(item => item.value == record.appointmentState);
      if (appointmentState) {
        return appointmentState.label;
      }
      return '';
    },
  },
  {
    title: '是否申请理赔',
    dataIndex: 'isApply',
    width: 100,
    customRender: ({ record }: Recordable) => {
      const isApplyArray = [
        { label: '未申请', value: 1 },
        { label: '已申请', value: 2 },
      ];
      const isApply: any = isApplyArray.find(item => item.value == record.isApply);
      if (isApply) {
        return isApply.label;
      }
      return '';
    },
  },
  {
    title: '理赔处理状态',
    dataIndex: 'isCheck',
    width: 100,
    customRender: ({ record }: Recordable) => {
      const isChecks = [
        { label: '未申请', value: '0' },
        { label: '受理中', value: '1' },
        { label: '已受理', value: '2' },
      ];
      const isCheck: any = isChecks.find(item => item.value == record.isCheck);
      if (isCheck) {
        return isCheck.label;
      }
      return '';
    },
  },
  {
    title: '开始时间',
    dataIndex: 'startTime',
    width: 100,
  },
  {
    title: '结束时间',
    dataIndex: 'endTime',
    width: 100,
  },
  {
    title: '联系电话',
    dataIndex: 'phone',
    width: 100,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'delayriskNo',
    label: '延误险编号',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'orderStatus',
    label: '付款状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '待付款', value: '1' },
        { label: '已付款', value: '2' },
        { label: '已退款', value: '3' },
      ],
    },
  },
  {
    field: 'isApply',
    label: '申请理赔状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '未申请', value: '1' },
        { label: '已申请', value: '2' },
      ],
    },
  },
  {
    field: 'isCheck',
    label: '理赔处理状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '未申请', value: '0' },
        { label: '受理中', value: '1' },
        { label: '已受理', value: '2' },
      ],
    },
  },
];

export const checkFormSchema: FormSchema[] = [
  {
    label: '延误险预约主键',
    field: 'delayriskId',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '预约状态',
    field: 'appointmentState',
    component: 'RadioGroup',
    required: true,
    defaultValue: 3,
    componentProps: {
      options: [
        { label: '购买成功', value: 1 },
        { label: '购买失败', value: 2 },
      ],
    },
  },
];
